<template>
	<view v-if="is_true">
		<uni-popup-input name="新增/编辑" @close="on_close">

			<view class=" ">
				<view class="p-10 bg-white">
					<view class="banmi_flex a-c p-10">
						<view class="f-16">
							名称：
						</view>
						<uni-easyinput v-model="find.name" placeholder="名称">
						</uni-easyinput>
					</view>
					<view class="p-20" style="width: 98%;" v-if="is_true">
						<BmEditor @change="confirm" :content="content" :height="500" :placeholder="placeholder"
							:mode="mode">
						</BmEditor>



					</view>

				</view>
			</view>


			<view class="a-c  p-b-20 banmi_input_edit">
				<view class="banmi_input_edit_name">
				</view>
				<view class="">
					<button @click="on_sava()" type="primary" style="width: 80px;" size="mini">保存</button>
				</view>
			</view>

		</uni-popup-input>
		<!-- 	颜色选择器 -->

	</view>
</template>

<script>
	import provinceData from '@/components/fd-picker/city-china.json';

	export default {
		components: {},
		props: {

		},
		data() {
			return {
				codetime: 8,
				find: {
					content:'',
					name:''
				},
				name: '',
				keya: '',
				is_init: false,
				is_true: false,
				content: '',
				placeholder: '请输入内容...',
				mode: 'default', // or 'simple'


			}
		},

		methods: {
			confirm(val) {
				this.content = val;
			},
			confirm_describe(val) {
				this.find.describe = val;
			},
			change_edition_issue(e) {
				this.find.edition_issue = e.detail.value;
			},
			change_edition_force(e) {
				this.find.edition_force = e.detail.value;
			},
			change_package_type(e) {
				this.find.package_type = e.detail.value;
				if (this.find.package_type == 0) {
					this.find.edition_silence = 0;
				}
			},
			change_edition_silence(e) {
				this.find.edition_silence = e.detail.value;
			},
			change_device(e) {
				this.find.device = e.detail.value;
			},
			async on_sava() {



				var url = this.img_url;
				this.content = this.content.replace(new RegExp(url, 'g'), "");

				let requestParams = {
					id: this.article_id,
					content: this.content,
					name: this.find.name
				};

				const ret = await this.Banmikeji.Settings_set_article_edit(requestParams);
				uni.showToast({
					title: ret.msg,
					icon: 'none'
				})

				if (ret.status == 200) {
					this.$emit("confirm");
					this.on_close();
				}






			},
			async init(article_id) {
				if(article_id==0){
					this.is_true = true;
					return
				}
		 
				this.article_id = article_id;
				let requestParams = {
					id: article_id,
				};

				const ret = await this.Banmikeji.Settings_set_article_find(requestParams);

				this.find = ret.data.find;
				this.img_url = ret.img_url;
				this.content = ret.data.find.content

				this.is_true = true;



			},

			on_close() {
				this.find = {};
				this.is_true = false;
			},
			//js分类方法

		}
	}
</script>

<style>
	button::after {
		border: none;
	}

	.top_head {
		background-color: #F8F8F8;
		width: 100%;
		top: 0;
		left: 0;
		z-index: 999;
		position: sticky
	}

	.but {
		width: 120rpx;
		height: 100rpx;
		padding: 0;
		border: 0;
		background-color: transparent;
		outline: none;
	}
</style>